"use strict";

/**
 * API定义
 */
//------------------------------------------------------------------
import vbHttp from "./http";
import axios from "axios";
//------------------------------------------------------------------

export default class Api {
    constructor(router, option) {
        this.vbAxios = new vbHttp(axios, router);
        if (option.response) this.vbAxios.response = option.response
        if (option.request) this.vbAxios.request = option.request
    }

    /**
     * post api调用
     * @param api
     * @param data
     * @param opts
     * @returns {AxiosPromise}
     */
    $post = (api, data, opts = {}) => {
        return this.vbAxios.post(api, data, opts)
    }
    /**
     * get api调用
     * @param api
     * @param data
     * @param opts
     * @returns {AxiosPromise}
     */
    $get = (api, data, opts = {}) => {
        return this.vbAxios.get(api, data, opts)
    }
    /**
     * upload api调用
     * @param api
     * @param data
     * @param opts
     * @returns {AxiosPromise}
     */
    $upload = (api, data, opts = {}) => {
        return this.vbAxios.upload(api, data, opts)
    }
    /**
     * download api调用
     * @param api
     * @param data
     * @param opts
     * @returns {AxiosPromise}
     */
    $download = (api, data, opts = {}) => {
        return this.vbAxios.download(api, data, opts)
    }
    /**
     * 系统登录
     * @param data
     * @param opts
     * @returns {*}
     */
    login = (data, opts = {}) => {
        return this.vbAxios.post("customer/vtuzx_login", data, opts)
    }
    /**
     * 系统退出
     * @param data
     * @param opts
     * @returns {*}
     */
    logout = (data, opts = {}) => {
        return this.vbAxios.post("customer/vtuzx_logout", data, opts)
    }
    /**
     * 修改密码
     * @param data
     * @param opts
     * @returns {Promise | Promise<unknown>}
     */
    changePassword = (data, opts = {}) => {
        return this.vbAxios.post("customer/vtuzx_change_password", data, opts)
    }
    /**
     * 修改个人信息
     * @param data
     * @param opts
     * @returns {Promise | Promise<unknown>}
     */
    updateUserInfo = (data, opts = {}) => {
        return this.vbAxios.post("customer/vtuzx_modify_user_info", data, opts)
    }

    getSession = (data, opts = {}) => {
        return this.vbAxios.post("getSession", data, opts)
    }
    refreshSession = (data, opts = {}) => {
        return this.vbAxios.post("refreshSession", data, opts)
    }
    findPassword = (data, opts = {}) => {
        return this.vbAxios.post("findPassword", data, opts)
    }
    resetPassword = (data, opts = {}) => {
        return this.vbAxios.post("resetPassword", data, opts)
    }
    sendTelCode = (data, opts = {}) => {
        return this.vbAxios.post("sendTelCode", data, opts)
    }
    checkTelCode = (data, opts = {}) => {
        return this.vbAxios.post("checkTelCode", data, opts)
    }
    register = (data, opts = {}) => {
        return this.vbAxios.post("register", data, opts)
    }

    // ※※※※※※※※※※※※※※※※※※※※※※※※※※※图片库API※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※
    addImgLibraryGroup = (data, opts = {}) => {
        return this.vbAxios.post("gallery/vtuzx_add_gallery_group", data, opts)
    }
    getImgLibraryGroup = (data, opts = {}) => {
        return this.vbAxios.post("gallery/vtuzx_get_gallery_group", data, opts)
    }
    getImgLibraryList = (data, opts = {}) => {
        return this.vbAxios.post("gallery/vtuzx_get_gallery", data, opts)
    }
    updateImgLibraryGroup = (data, opts = {}) => {
        return this.vbAxios.post("gallery/vtuzx_update_gallery_group", data, opts)
    }
    uploadImgLibrary = (data, opts = {}) => {
        return this.vbAxios.upload("gallery/vtuzx_upload_gallery", data, opts)
    }
    deleteImgLibraryGroup = (data, opts = {}) => {
        return this.vbAxios.post("gallery/vtuzx_delete_gallery_group", data, opts)
    }
    deleteImages = (data, opts = {}) => {
        return this.vbAxios.post("gallery/vtuzx_delete_gallery", data, opts)
    }
    moveImagesGroup = (data, opts = {}) => {
        return this.vbAxios.post("gallery/vtuzx_move_gallery_group", data, opts)
    }

    /******************系统配置相关API**************************************/
    getSystemConfig = (data, opts = {}) => {
        return this.vbAxios.post("system/get_config", data, opts)
    }
    getInitData = (data, opts = {}) => {
        return this.vbAxios.post("system/get_init_data", data, opts)
    }
    getSystemMaster = (data, opts = {}) => {
        return this.vbAxios.post("system/get_system_master", data, opts)
    }

    /******************项目菜单相关API**************************************/
    getMenuList = (data, opts = {}) => {
        return this.vbAxios.post("system/get_menu_list", data, opts)
    }
    addMenu = (data, opts = {}) => {
        return this.vbAxios.post("system/add_menu", data, opts)
    }
    deleteMenu = (data, opts = {}) => {
        return this.vbAxios.post("system/remove_menu", data, opts)
    }
    updateMenu = (data, opts = {}) => {
        return this.vbAxios.post("system/modify_menu", data, opts)
    }
    /******************接口管理相关API**************************************/
    getApiList = (data, opts = {}) => {
        return this.vbAxios.post("system/get_api_list", data, opts)
    }
    addApi = (data, opts = {}) => {
        return this.vbAxios.post("system/add_api", data, opts)
    }
    deleteApi = (data, opts = {}) => {
        return this.vbAxios.post("system/delete_api", data, opts)
    }
    updateApi = (data, opts = {}) => {
        return this.vbAxios.post("system/update_api", data, opts)
    }

    /******************角色管理相关API**************************************/
    getCharacterList = (data, opts = {}) => {
        return this.vbAxios.post("setting/character/get_list", data, opts)
    }
    getDepartmentList = (data, opts = {}) => {
        return this.vbAxios.post("basic/get_department_list", data, opts)
    }
    addCharacter = (data, opts = {}) => {
        return this.vbAxios.post("setting/character/add", data, opts)
    }
    deleteCharacter = (data, opts = {}) => {
        return this.vbAxios.post(`setting/character/delete_multi`, data, opts)
    }
    updateCharacter = (data, opts = {}) => {
        return this.vbAxios.post(`setting/character/${data.id}/update`, data, opts)
    }
    updateCharacterPower = (data, opts = {}) => {
        return this.vbAxios.post(`setting/character/${data.id}/update_new`, data, opts)
    }
    getEditablePower = (data, opts = {}) => {
        return this.vbAxios.post("setting/character/get_editable_power", data, opts)
    }

    /******************机构相关API**************************************/
    getOrganList = (data, opts = {}) => {
        return this.vbAxios.post("setting/organization/get_list", data, opts)
    }
    addOrgan = (data, opts = {}) => {
        return this.vbAxios.post("setting/organization/add", data, opts)
    }
    deleteOrgan = (data, opts = {}) => {
        return this.vbAxios.post(`setting/organization/delete_multi`, data, opts)
    }
    updateOrgan = (data, opts = {}) => {
        return this.vbAxios.post(`setting/organization/${data.id}/update`, data, opts)
    }

    /******************字典相关API**************************************/
    getParentDictionaryList = (data, opts = {}) => {
        return this.vbAxios.post("setting/dict/get_list", data, opts)
    }
    addParentDictionary = (data, opts = {}) => {
        return this.vbAxios.post("setting/dict/add", data, opts)
    }
    deleteParentDictionary = (data, opts = {}) => {
        return this.vbAxios.post(`setting/dict/delete_multi`, data, opts)
    }
    updateParentDictionary = (data, opts = {}) => {
        return this.vbAxios.post(`setting/dict/${data.id}/update`, data, opts)
    }
    getChildDictionaryList = (data, opts = {}) => {
        return this.vbAxios.post(`setting/dict/${data.dictId}/get_detail_list`, data, opts)
    }
    getChildDictionaryListByKeys = (data, opts = {}) => {
        return this.vbAxios.post(`setting/dict/get_options_by_token`, data, opts)
    }
    addChildDictionary = (data, opts = {}) => {
        return this.vbAxios.post(`setting/dict/${data.dictId}/add_detail`, data, opts)
    }
    deleteChildDictionary = (data, opts = {}) => {
        return this.vbAxios.post(`setting/dict/${data.dictId}/delete_detail_multi`, data, opts)
    }
    updateChildDictionary = (data, opts = {}) => {
        return this.vbAxios.post(`setting/dict/${data.dictId}/update_detail`, data, opts)
    }

    /******************载体相关API**************************************/
    getCarrierList = (data, opts = {}) => {
        return this.vbAxios.post("admin/get_factory_list", data, opts)
    }
    addCarrier = (data, opts = {}) => {
        return this.vbAxios.post("admin/add_factory", data, opts)
    }
    deleteCarrier = (data, opts = {}) => {
        return this.vbAxios.post("admin/remove_factory", data, opts)
    }
    updateCarrier = (data, opts = {}) => {
        return this.vbAxios.post("admin/modify_factory", data, opts)
    }
    getCarrierDetail = (data, opts = {}) => {
        return this.vbAxios.post("admin/get_factory_detail", data, opts)
    }
    importCarrier = (data, opts = {}) => {
        return this.vbAxios.upload("admin/factory_excel", data, opts)
    }

    /******************员工相关API**************************************/
    getCustomerList = (data, opts = {}) => {
        return this.vbAxios.post("setting/customer/get_list", data, opts)
    }
    addCustomer = (data, opts = {}) => {
        return this.vbAxios.post("setting/customer/add", data, opts)
    }
    deleteCustomer = (data, opts = {}) => {
        return this.vbAxios.post(`setting/customer/delete_multi`, data, opts)
    }
    updateCustomer = (data, opts = {}) => {
        return this.vbAxios.post(`setting/customer/${data.id}/update`, data, opts)
    }
}
